<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>scraper.mk</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/custom_jquery.js"></script>
<script type="text/javascript" src="js/jquery.pstrength-min.1.2.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
    $(function() {
        $('#password').pstrength();
    });
</script>

<script type="text/javascript">
$(document).ready(function(){
    
    $("#loginbox").show();
    $("#registerbox").hide();
    $("#forgotbox").hide();
    $(".error").hide();
    if($.cookie("screen") == null)
        $.cookie("screen", "login", { expires : 1 });
    else{
        var window = $.cookie("screen");
        if(window == 'login'){
            $("#loginbox").show();
            $("#registerbox").hide();
            $("#forgotbox").hide();
            $(".error").hide();
        }
        if(window == 'register'){
            $("#loginbox").hide();
            $("#registerbox").show();
            $("#forgotbox").hide();
            $(".error").hide();
        }
        if(window == 'forgot'){
            $("#loginbox").hide();
            $("#registerbox").hide();
            $("#forgotbox").show();
            $(".error").hide();
        }
    };
    
    $(".register").click(function(){
        $("#loginbox").hide();
        $("#registerbox").show();
        $("#forgotbox").hide();
        $(".error").hide();
        $.cookie("screen", "register");
    });
    
    $(".forgot-pwd").click(function(){
        $("#loginbox").hide();
        $("#registerbox").hide();
        $("#forgotbox").show();
        $(".error").hide();
        $.cookie("screen", "forgot");
    });
    
    $(".back-login").click(function(){
        $.cookie("screen", null);
        document.location.href = '<?php echo base_url(); ?>';
    });
    
    $("#login_btn").click(function(){
        $(".error").hide();
        $.cookie("screen", "login", { expires : 1 });
        var mail = $('#lemail').attr('value');
        var pass = $('#lpassword').attr('value');
        $.post('<?php echo base_url();?>login', { email: mail, password: pass }, function(data){
            if(data == 1){
                document.location.href = '<?php echo base_url(); ?>index.php';
            }
            else{
                $('#lemail').val('');
                $('#lpassword').val('');
                $(".error").show();
                $('.error').html(data);
            }
                
        });
    });
    
    $("#register_btn").click(function(){
        $(".error").hide();
        $.cookie("screen", "register", { expires : 1 });
        var fn = $('#name').attr('value');
        var mail = $('#email').attr('value');
        var pwd = $('#password').attr('value');
        $.post('<?php echo base_url();?>register', { name: fn,  email: mail, password: pwd }, function(data){
            $('#name').val('');
            $('#email').val('');
            $('#password').val('');
            $(".error").show();
            $('.error').html(data);
        });
    });
    
    $("#forgot_btn").click(function(){
        $(".error").hide();
        $.cookie("screen", "forgot", { expires : 1 });
        var mail = $('#femail').attr('value');
        $.post('<?php echo base_url();?>forgot', { email: mail }, function(data){
            $('#femail').val('');
            $(".error").show();
            $('.error').html(data);
        });
    });
    
});
</script>
</head>
<body id="login-bg"> 
 
<div id="login-holder">

	<div id="logo-login">
            <a href="index.php">Web application for ...</a>
	</div>
    
	<div class="clear"></div>
        
        <div id="loginbox">
            <form action="<?php echo base_url(); ?>login" method="post" >    
                <div id="login-inner">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <th>Email</th>
                            <td><input type="text" id="lemail" class="login-inp" name="username"/></td>
                        </tr>
                        <tr>
                            <th>Password</th>
                            <td><input type="password" id="lpassword" class="login-inp" name="password"/></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td valign="top"><input type="checkbox" class="checkbox-size" id="login-check" /><label for="login-check">Remember me</label></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><input type="button" id="login_btn" class="submit-login"  /></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td><div class="error"></div></td>
                        </tr>
                    </table>
                </div>
            </form>     	
            <div class="clear"></div>
            <a href="#" class="register">Register</a>
            <a href="#" class="forgot-pwd">Forgot Password?</a>
        </div>
 
	<div id="forgotbox">
            <div id="forgotbox-text">Please send us your email and we'll reset your password.</div>
            <form action="<?php echo base_url(); ?>forgot" method="post">
                <div id="forgot-inner">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <th>Email address:</th>
                            <td><input type="text" id="femail" value="" name="email" class="login-inp" /></td>
                        </tr>
                        <tr>
                            <th> </th>
                            <td><input id="forgot_btn" type="button" class="submit-login"  /></td>
                        </tr>
                        <tr>
                            <th> </th>
                            <td><div class="error"></div></td>
                        </tr>
                    </table>
                </div>
            </form>    
            <div class="clear"></div>
            <a href="<?php echo base_url(); ?>" class="back-login">Back to login</a>
	</div>
        
        <div id="registerbox">
		<div id="register-text">Enter the required fields for successful registration !</div>
                <form action="<?php echo base_url()?>register" method="post">
                    <div id="register-inner">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <th>Name:</th>
                                <td><input id="name" type="text" value="" name="name" class="login-inp" /></td>
                            </tr>
                            <tr>
                                <th>Email address:</th>
                                <td><input id="email" type="text" value="" name="email" class="login-inp" /></td>
                            </tr>
                            <tr>
                                <th>Password:</th>
                                <td><div class="pass_check"><input id="password" type="password" value="" name="password" class="login-inp" /></div></td>
                            </tr>
                            <tr>
                                <th> </th>
                                <td><input id="register_btn" type="button" class="submit-login"  /></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td><div class="error"></div></td>
                            </tr>
                        </table>
                    </div>
                </form>

		<div class="clear"></div>
		<a href="<?php echo base_url(); ?>" class="back-login">Back to login</a>
	</div>

</div>

</body>
</html>